package com.sx.gongzhong.pest;

import com.sx.gongzhong.model.ExposureBean;
import com.sx.gongzhong.model.HeadParamBean;
import com.sx.gongzhong.model.ReplyUserBean;
import com.sx.gongzhong.net.ApiManager;
import com.sx.gongzhong.net.BaseCallBack;
import com.sx.gongzhong.model.BasePageListBean;
import com.sx.gongzhong.view.IExposureListView;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by XZY on 2018/1/9.
 * 爆料列表
 */

public class ExposureListPest {

    private IExposureListView listView;

    public ExposureListPest(IExposureListView listView) {
        this.listView = listView;
    }

    /**
     * @param brokeNewsTypeId 爆料类型id
     * @param fastSearch 快速检索
     * @param page 页
     * @param rows 条数
     */
    public void loadExposureList(String brokeNewsTypeId, String fastSearch,int page ,int rows ){
        Map<String,Object> map= new HashMap<>();
        map.put("sourcesState",0);
        map.put("brokeNewsTypeId", brokeNewsTypeId);
        map.put("title", fastSearch);
        map.put("page", page);
        map.put("rows", rows);
        new ApiManager().loadExposureList(map, new BaseCallBack<ReplyUserBean.BaseResult<BasePageListBean<ExposureBean>>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<BasePageListBean<ExposureBean>> response) {
                listView.loadExposureList(response.getData().rows,response.getData().records);
            }

            @Override
            public void onFailures(String message) {
                listView.showError(message);
            }
        });

    }
    //我的爆料
    public void loadMyAddExposureList(String brokeNewsTypeId, String fastSearch, int page, int rows) {
        Map<String,Object> map= HeadParamBean.getHead();
        map.put("sourcesState",0);
        map.put("brokeNewsTypeId", brokeNewsTypeId);
        map.put("title", fastSearch);
        map.put("page", page);
        map.put("rows", rows);
        new ApiManager().loadMyAddExposureList(map, new BaseCallBack<ReplyUserBean.BaseResult<BasePageListBean<ExposureBean>>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<BasePageListBean<ExposureBean>> response) {
                listView.loadExposureList(response.getData().rows,response.data.records);
            }

            @Override
            public void onFailures(String message) {
                listView.showError(message);
            }
        });

    }
}
